package com.qianxun;

import com.qianxun.watchdog.util.FileUtil;

import java.io.File;
import java.io.IOException;
import java.util.Set;

/**
 * @author: huwei
 * @date: 2020/10/19 16:25
 * @version: 1.0.0
 */
public class OriginalJavaFileToTemplate {
    public static void main(String[] args) {
        Set<String> files = FileUtil.fileListAsRecursion("src/main/java/com/qianxun/watchdog");
        String root = "/application/monitor-watchdog/";
        files.forEach(file->{
            try {
                byte[] bytes = FileUtil.read(file);

                String target = root + file.substring(file.indexOf("src/main/java/") + "src/main/java/".length()) + ".tmp";

                File dir = new File(target.substring(0,target.lastIndexOf("/")));
                if(!dir.exists()){
                    dir.mkdirs();
                }
                File f = new File(target);
                if(!f.exists()) {
                    f.createNewFile();
                }


                byte[] bytes1 = new String(bytes ,"UTF-8").getBytes("UTF-8");

                FileUtil.write(f ,bytes1 ,false);



            } catch (IOException e) {
                e.printStackTrace();
            }
        });
    }
}
